<template>
  <div class="body" v-loading="loading.status">
    <div class="table_content">
      <!-- <div class="table_operate">
        <el-button class="btn_add" type="primary" @click="handleToGoCreate"
          >添加</el-button
        >
      </div> -->

      <div class="table-card">
        <el-table
          class="table"
          :data="tableData"
          :row-class-name="tableRowClassName"
          :border="true"
          size="mini"
        >
          <el-table-column prop="name" label="名称"> </el-table-column>
          <el-table-column label="操作">
            <template slot-scope="scope">
              <el-link
                class="handle"
                type="primary"
                @click="handleTableEdit(scope.$index, scope.row)"
                >编辑</el-link
              >
            </template>
          </el-table-column>
        </el-table>
      </div>
    </div>
  </div>
</template>

<script>
import { apiConfigContractListpage } from "@/api/apiConfig";
import { paramsDeleteNull } from "@/utils/common";
import { loading_start, loading_end } from "@/utils/loadingUtil";
export default {
  name: "Index",
  data() {
    return {
      tableParams: {
        page: 1,
        size: 15,
        business_uid: "",
        o_id: "",
        loan_type: "",
        push_status: "",
        entry_status: "",
        plan_name: "",
        status: "normal",
      },
      tableData: null,
      currentPage4: 1,
      business_select: [],
      organization_select: [],
      fromViewCofing: {
        input_width: "120px",
        label_width: "120px",
      },
      loading: {
        status: false,
        loadingCount: 0,
      },
    };
  },
  created() {
    this.loadTableData();
  },
  methods: {
    // 列表请求
    loadTableData() {
      const _this = this;
      loading_start(this);
      var tableParamsData = { ..._this.tableParams };
      apiConfigContractListpage(tableParamsData)
        .then((response) => {
          const result = response;
          _this.tableData = result.data.list;
          loading_end(this);
        })
        .catch(function (result) {
          _this.$message.error(result.msg);
          _this.tableData = null;
        });
    },
    // 表格行状态
    tableRowClassName({ row, rowIndex }) {
      if (row["status"] == "stop") {
        return "discard-row";
      }
    },
    // 表格操作
    handleTableEdit(index, row) {
      this.$router.push({
        path: "/operate/contractUpdate",
        query: { id: row.id, key: row.key, title: row.name },
      });
    },
    // 开始加载
    loading_start() {
      const _this = this;
      if (_this.loading.loadingCount === 0) {
        // 显示加载状态
        _this.loading.status = true;
      }
      _this.loading.loadingCount += 1;
    },
    // 停止加载
    loading_end() {
      const _this = this;
      if (_this.loading.loadingCount > 0) {
        _this.loading.loadingCount -= 1;
        if (_this.loading.loadingCount === 0) {
          _this.loading.status = false;
        }
      }
    },
  },
};
</script>

<style lang="scss"></style>